package com.example.wm.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.wm.common.Result;
import com.example.wm.common.ResultData;
import com.example.wm.entity.HenDeiShunFitting;
import com.example.wm.entity.HenDeiShunoutorinStrorage;
import com.example.wm.service.HenDeiShunFittingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
//恒德顺配件
@RequestMapping("/HenDeiShunFitting")
public class HenDeiShunFittingController {
    @Resource
    private HenDeiShunFittingService henDeiShunFittingService;
    @PostMapping("/insert")
    public Result insert(@RequestBody HenDeiShunFitting henDeiShunFitting){
        henDeiShunFittingService.save(henDeiShunFitting);
        return ResultData.success("插入成功");
    }
    //搜索
    @PostMapping("/search")
    public Result search(@RequestBody HenDeiShunFitting henDeiShunFitting){
        LambdaQueryWrapper<HenDeiShunFitting> lq=new LambdaQueryWrapper<>();
        lq.like(HenDeiShunFitting::getModeltype,henDeiShunFitting.getModeltype());
        lq.eq(HenDeiShunFitting::getStatus,"已入库");
        List<HenDeiShunFitting> list=henDeiShunFittingService.list(lq);

        return ResultData.success(list);
    }

    @PostMapping("/getlist")
    public Result getlist(){

        LambdaQueryWrapper<HenDeiShunFitting> lq=new LambdaQueryWrapper<>();
        lq.eq(HenDeiShunFitting::getStatus,"已入库");
        List<HenDeiShunFitting> list=henDeiShunFittingService.list(lq);
        return ResultData.success(list);
    }

    @PostMapping("/updatebyid")
    public Result updatebyid(@RequestBody HenDeiShunFitting henDeiShunFitting){
     henDeiShunFittingService.updateById(henDeiShunFitting);
        return ResultData.success(1);
    }


}
